package com.easychat.controller;

import com.easychat.common.PageResult;
import com.easychat.common.Result;
import com.easychat.entity.UserInfoBeauty;
import com.easychat.service.UserInfoBeautyService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 靓号表(UserInfoBeauty)表控制层
 *
 * @author makejava
 * @since 2024-10-01 17:32:20
 */
@RestController
@RequestMapping("userInfoBeauty")
public class UserInfoBeautyController {
    /**
     * 服务对象
     */
    @Resource
    private UserInfoBeautyService userInfoBeautyService;



    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public Result<UserInfoBeauty> queryById(@PathVariable("id") Integer id) {
        return Result.ok(this.userInfoBeautyService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param userInfoBeauty 实体
     * @return 新增结果
     */
    @PostMapping
    public Result add(UserInfoBeauty userInfoBeauty) {
        boolean insert = userInfoBeautyService.insert(userInfoBeauty);
        if(insert){
            return Result.ok();
        }
        return Result.fail();
    }

    /**
     * 编辑数据
     *
     * @param userInfoBeauty 实体
     * @return 编辑结果
     */
    @PutMapping
    public Result edit(UserInfoBeauty userInfoBeauty) {
        boolean update = userInfoBeautyService.update(userInfoBeauty);
        if(update){
            return Result.ok("修改成功！");
        }
        return Result.fail("修改失败~");
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public Result<Boolean> deleteById(Integer id) {
        boolean bl = userInfoBeautyService.deleteById(id);
        if(bl){
            return Result.ok();
        }
        return Result.fail();
    }

}

